package com.webchat.aigc.service;


import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.domain.vo.response.mess.ChatMessageResponseVO;
import com.webchat.rmi.ugc.ChatMessageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ChatMessageService {

    @Autowired
    private ChatMessageClient chatMessageClient;

    /**
     * 查询两个账号的最新对话消息
     *
     * @param sourceUserId
     * @param targetUserId
     * @param size
     * @return
     */
    public List<ChatMessageResponseVO> queryChatMessages(String sourceUserId, String targetUserId, int size) {

        APIResponseBean<List<ChatMessageResponseVO>> responseBean =
                chatMessageClient.list(sourceUserId, targetUserId, size, null, null);
        if (APIResponseBeanUtil.isOk(responseBean)) {
            return responseBean.getData();
        }
        return Collections.emptyList();
    }
}
